<html>
<head>
  <script type="text/tiscript">
  
    
       
    
    function self.ready()
    {
      const items = ["apple","orange","lime","lemon","pear","banan","kiwi","pineapple"];
       
      function* forward()
      {
        for( var i = 0; i < items.length; ++i )
          yield items[i];
      }
      function* backward()
      {
        for( var i = items.length - 1; i >=0 ; --i )
          yield items[i];
      }

      function* step()
      {
        var i = 0;
        while( i < items.length ) {
          var n = yield items[i];
          debug log: n;
          i += n || 1;
        }
      }

      var ol = self.select("ol#forward");
      for(var item in forward())
        ol.append([li: item]);
      ol = self.select("ol#backward");
      for(var item in backward())
        ol.append([li: item]);

      ol = self.select("ol#step");
      var iterator = step();
      while(var item = iterator.next(2))
        ol.append([li:item]);
        
    }
    
  </script>
</head>
<body>
  Fruits, forward:
  <ol #forward />
  Fruits, backward:
  <ol #backward />
  Fruits, odd (iterator.next() test):
  <ol #step />
  
</body>
</html>